/**
  ******************************************************************************
  * @file   :   .c
  * @version:
  * @author :
  * @brief  :
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; Copyright(c) . BLUEX Microelectronics.
  * All rights reserved.</center></h2>
  *
  *
  ******************************************************************************
  */
/* config --------------------------------------------------------------------*/

/* includes ------------------------------------------------------------------*/
#include "shell_api.h"
#include <stdio.h>

/* private define ------------------------------------------------------------*/

/* private typedef -----------------------------------------------------------*/

/* private variables ---------------------------------------------------------*/

/* private macros ------------------------------------------------------------*/

/* exported variables --------------------------------------------------------*/

/* exported function prototypes ----------------------------------------------*/

/*============================= private function =============================*/

/** ---------------------------------------------------------------------------
 * @brief   :
 * @note    :
 * @param   :
 * @param   :
 * @retval  :
-----------------------------------------------------------------------------*/
static void prv_sum( char argc, char * argv )
{
    int arg;
    int sum = 0;
    for( uint8_t i = 1; i < argc ; i++ ) {
        sscanf( &( argv[argv[i]] ), "%d", &arg );
        sum += arg;
    }
    printf( "sum:%d\r\n", sum );
}
/*========================= end of private function ==========================*/


/*============================= exported function ============================*/

/** ---------------------------------------------------------------------------
 * @brief   :
 * @note    :
 * @param   :
 * @param   :
 * @retval  :
-----------------------------------------------------------------------------*/
void uart_shell_test( void )
{
    bxs_init();

    /* add user cmd */

    if( !bxs_add_cmd( "sum", prv_sum, "calculate the sum of paras " ) ) {
        printf( "add cmd fail\r\n" );
        return ;
    }

    /* end of add user cmd */
    while( 1 ) {
        bxs_run();
    }
}
/*========================= end of exported function =========================*/


/*============================= import function ==============================*/
/*=========================== end of import function =========================*/


/*============================ interrupt function ============================*/
/*========================= end of interrupt function ========================*/


/******************** (C) COPYRIGHT BLUEX **********************END OF FILE****/
